/*
 * @Author: monet hanxu@huaun.com
 * @Date: 2023-09-15 14:18:43
 * @LastEditors: zhangyonggui
 * @LastEditTime: 2023-10-20 16:34:20
 * @FilePath: /h-radar-Attack/store/detail.js
 * @Description: 攻击面详情接口
 */
import $axios from '../services/http';

const state = () => ({
  exposed: '/exposed',
  attack: '/attack',
});

const mutations = {};
const actions = {
  // 根据id获取漏洞详情
  async getAssetVulById({ state, rootState }, data) {
    return await $axios.get(
      `${rootState.routeServiceV2}${state.attack}/vul/${data}`,
    );
  },
  // 根据id获取资产列表
  async getAssetList({ state, rootState }, data) {
    return await $axios.get(
      `${rootState.routeServiceV2}${state.attack}/affect-assets/${data}`,
    );
  },
  // 详情页左侧信息
  async getBaseInfo({ state, rootState }, data) {
    return await $axios.get(
      `${rootState.routeServiceV2}${state.exposed}/asset/asset-base-info`,
      data,
    );
  },
  
  // 根据id获取web详情
  async getWebById({ state, rootState }, data) {
    return await $axios.get(
      `${rootState.routeServiceV2}${state.exposed}/web/${data}`,
    );
  },
  // 根据id获取ip详情
  async getIpById({ state, rootState }, data) {
    return await $axios.get(
      `${rootState.routeServiceV2}${state.exposed}/ip/${data}`,
    );
  },
  // 根据id获取domain详情
  async getDomainById({ state, rootState }, data) {
    return await $axios.get(
      `${rootState.routeServiceV2}${state.exposed}/domain/${data}`,
    );
  },
  // 根据id获取code详情
  async getCodeById({ state, rootState }, data) {
    return await $axios.get(
      `${rootState.routeServiceV2}${state.exposed}/code-file/${data}`,
    );
  },
  // 根据id获取app详情
  async getAppById({ state, rootState }, data) {
    return await $axios.get(
      `${rootState.routeServiceV2}${state.exposed}/app/${data}`,
    );
  },
  // 根据id获取公众号详情
  async getOfficialAccountById({ state, rootState }, data) {
    return await $axios.get(
      `${rootState.routeServiceV2}${state.exposed}/official-accounts/${data}`,
    );
  },
  // 根据id获取小程序详情
  async getMiniProgramById({ state, rootState }, data) {
    return await $axios.get(
      `${rootState.routeServiceV2}${state.exposed}/mini-program/${data}`,
    );
  },
  // 根据id获取供应商详情
  async getSupplierById({ state, rootState }, data) {
    return await $axios.get(
      `${rootState.routeServiceV2}${state.exposed}/supplier/${data}`,
    );
  },
  // 根据id获取暗网信息详情
  async getDarknetById({ state, rootState }, data) {
    return await $axios.get(
      `${rootState.routeServiceV2}${state.exposed}/darknet/${data}`,
    );
  },
  // 详情-获取信息系统body
  async getWebBody({ state, rootState }, data) {
    return await $axios.get(
      `${rootState.routeServiceV2}${state.exposed}/web-body/${data}`,
    );
  },
  // 根据资产变更记录
  async getAssetChanged({ state, rootState }, data) {
    return await $axios.post(
      `${rootState.routeServiceV2}${state.exposed}/data-history/page-data-history`,
      data,
    );
  },
  // 根据资产证书信息
  async getCertById({ state, rootState }, data) {
    return await $axios.post(
      `${rootState.routeServiceV2}${state.exposed}/cert/page-by-web-id`,
      data,
    );
  },
  // 通过web Id获取ICP
  async getWebIcpInfo({ state, rootState }, data) {
    return await $axios.get(
      `${rootState.routeServiceV2}${state.exposed}/icp/query-by-web-id?webId=${data}`,
    );
  },
  // 通过domain Id获取ICP
  async getDomainIcpInfo({ state, rootState }, data) {
    return await $axios.get(
      `${rootState.routeServiceV2}${state.exposed}/icp/query-by-domain-id?domainId=${data}`,
    );
  },
  // 获取暴露风险
  async getAnalysisExposureRisk({ state, rootState }, data) {
    return await $axios.get(
      `${rootState.routeServiceV2}${state.exposed}/asset-analysis/query-exposure-risk`,
      data,
    );
  },
  // 获取暴露程度
  async getAnalysisExposureLevel({ state, rootState }, data) {
    return await $axios.get(
      `${rootState.routeServiceV2}${state.exposed}/asset-analysis/query-exposure-level`,
      data,
    );
  },
  // 获取易受攻击性
  async getAnalysisExposureVulnerability({ state, rootState }, data) {
    return await $axios.get(
      `${rootState.routeServiceV2}${state.exposed}/asset-analysis/query-exposure-vulnerability`,
      data,
    );
  },
  // 获取易受攻击性
  async getWhoisById({ state, rootState }, data) {
    return await $axios.get(
      `${rootState.routeServiceV2}${state.exposed}/whois/query-by-domain-id`,
      data,
    );
  },
  // ip关联端口号分页查询
  async getPortById({ state, rootState }, data) {
    return await $axios.post(
      `${rootState.routeServiceV2}${state.exposed}/ip-port/page`,
      data,
    );
  },
  // 详情-代码文件敏感片段分页查询
  async getCodeFileById({ state, rootState }, data) {
    return await $axios.post(
      `${rootState.routeServiceV2}${state.exposed}/code-file/page-sensitive-part`,
      data,
    );
  },
  // 详情-分页查询企业供应商的合同列表
  async getSupplierList({ state, rootState }, data) {
    return await $axios.post(
      `${rootState.routeServiceV2}${state.exposed}/supplier/page-supply-contract`,
      data,
    );
  },
  // 通过域名id获取域名解析记录
  async getResolutionById({ state, rootState }, data) {
    return await $axios.get(
      `${rootState.routeServiceV2}${state.exposed}/domain-resolution/query-by-domain-id`,
      data,
    );
  },
  // 子域名分页查询
  async getSubDomainById({ state, rootState }, data) {
    return await $axios.post(
      `${rootState.routeServiceV2}${state.exposed}/domain/subdomain/page`,
      data,
    );
  },
  // 获取详情页-资产暴露路径
  async getExposurePath({ state, rootState }, data) {
    return await $axios.get(
      `${rootState.routeServiceV2}${state.exposed}/asset-expose-path?id=${data.assetId}&businessType=${data.assetType}`,
    );
  },
  // 获取详情页攻击面分析-图谱
  async getSurfaceAnalysis({ state, rootState }, data) {
    return await $axios.get(
      `${rootState.routeServiceV2}/attack/asset-vul-location/attack-path-list?assetId=${data.assetId}&assetType=${data.assetType}`,
    );
  },
  // 获取详情页-关联暴露面
  async getRelationships({ state, rootState }, data) {
    return await $axios.post(
      `${rootState.routeServiceV2}/hugegraph/search/relationships`,
      data,
    );
  },
  // 获取详情页攻击面分析-资产弱点
  async getWeaknessList({ state, rootState }, data) {
    return await $axios.post(
      `${rootState.routeServiceV2}/attack/asset-vul-location/page-weakness`,
      data,
    );
  },
  // web目录结构树查询-图谱
  async getWebDir({ state, rootState }, data) {
    return await $axios.get(
      `${rootState.routeServiceV2}${state.exposed}/web-dir/${data}`,
    );
  },

};

export default {
  namespaced: true, // 有命名空间
  state,
  mutations,
  actions,
};
